package endcourseproject;

public class RobotTravelCmdMsg extends RobotMsg {

	public static final int IntegerLenInBytes = Integer.SIZE / Byte.SIZE;   

	public static final int flockIDOffset = RobotMsg.msgDataOffset;   
	public static final int flockIDLen = IntegerLenInBytes;   

	public static final int angleOffset = flockIDOffset + flockIDLen;   
	public static final int angleLen = IntegerLenInBytes;   
	public static final int magnitudeOffset = angleOffset + angleLen;   
	public static final int magnitudeLen = IntegerLenInBytes;   

	
	public static final int MsgLen = magnitudeOffset+magnitudeLen;  

	public RobotTravelCmdMsg(RobotMsg msg)
	{
		super(msg.getRawMsg());
	}

	public RobotTravelCmdMsg()
	{
		super(new byte[MsgLen]);
		byte[] msgd = this.getRawMsg();
        //initialize all bytes 2 0xFF
		for(int i= 0; i < msgd.length;i++)
		{
			msgd[i] = (byte) 0xFF;
		}
		this.setMsgType(TravelCmdMsgType);
	}

	public int getAngle() {
		return Utils.CopyBytesToInt(this.getRawMsg(),angleOffset);
	}

	public void setAngle(int angle) {
		Utils.CopyIntToBytes(this.getRawMsg(),angleOffset, angle);
	}

	public int getMagnitude() {
		return Utils.CopyBytesToInt(this.getRawMsg(),magnitudeOffset);
	}

	public void setMagnitude(int magnitude) {
		Utils.CopyIntToBytes(this.getRawMsg(),magnitudeOffset, magnitude);
	}

	public int getFlockID() {
		return Utils.CopyBytesToInt(this.getRawMsg(),flockIDOffset);
	}

	public void setFlockID(int flockID) {
		Utils.CopyIntToBytes(this.getRawMsg(),flockIDOffset, flockID);
	}

}
